package com.ziyia.uilayouttest;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

import androidx.appcompat.widget.LinearLayoutCompat;

public class TitleLayout extends LinearLayout {
    private Context context;
    Button left, right;

    public TitleLayout(Context context) {
        super(context);
    }

    public TitleLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        LayoutInflater.from(context).inflate(R.layout.title, this);
        this.context = context;
        left = findViewById(R.id.titleBack);
        right = findViewById(R.id.titleEdit);


        left.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Activity activity = (Activity) context;
                activity.finish();
            }
        });

        right.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context, "You clicked Edit Button", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
